home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Information / Digests / CSMP Digest / volume 3 / csmp-digest-v3-046 / doubleCR.1 < prev   
Encoding:
Text File  |  1995-12-31  |  82.0 KB  |  2,272 lines

  1. C.S.M.P. Digest             Wed, 20 Jul 94       Volume 3 : Issue 46
  2.  
  3. Today's Topics:
  4.  
  5.         3D Rotational examples - Help wanted
  6.         CASE Tools for Macintosh
  7.         Debugging an applet properly (AppleScript)
  8.         GWorlds vs. Offscreens
  9.         GWorlds: When to lock pixels?
  10.         How do you write TIFFs?
  11.         How to tell Energy Saver to turn the monitor on or off
  12.         Newbie Gworld questions.
  13.         Patching Trap ExitToShell using UniversalProcPtr's
  14.         Porting from Unix to Mac - Summary
  15.         Problems with Metrowerks vs. MPW 68k C calling conventions
  16.         Special #define for Univ. Hdrs?
  17.         Why does THINK C use a jump table?
  18.  
  19.  
  20.  
  21. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  22. (pottier@clipper.ens.fr).
  23.  
  24. The digest is a collection of article threads from the internet newsgroup
  25. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  26. regularly and want an archive of the discussions.  If you don't know what a
  27. newsgroup is, you probably don't have access to it.  Ask your systems
  28. administrator(s) for details.  If you don't have access to news, you may
  29. still be able to post messages to the group by using a mail server like
  30. anon.penet.fi (mail help@anon.penet.fi for more information).
  31.  
  32. Each issue of the digest contains one or more sets of articles (called
  33. threads), with each set corresponding to a 'discussion' of a particular
  34. subject.  The articles are not edited; all articles included in this digest
  35. are in their original posted form (as received by our news server at
  36. nef.ens.fr).  Article threads are not added to the digest until the last
  37. article added to the thread is at least two weeks old (this is to ensure that
  38. the thread is dead before adding it to the digest).  Article threads that
  39. consist of only one message are generally not included in the digest.
  40.  
  41. The digest is officially distributed by two means, by email and ftp.
  42.  
  43. If you want to receive the digest by mail, send email to listserv@ens.fr
  44. with no subject and one of the following commands as body:
  45.     help                        Sends you a summary of commands
  46.     subscribe csmp-digest Your Name    Adds you to the mailing list
  47.     signoff csmp-digest            Removes you from the list
  48. Once you have subscribed, you will automatically receive each new
  49. issue as it is created.
  50.  
  51. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  52. Questions related to the ftp site should be directed to
  53. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  54. digest are available there.
  55.  
  56. Also, the digests are available to WAIS users.  To search back issues
  57. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  58. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  59.  
  60.  
  61. -------------------------------------------------------
  62.  
  63. >From Malicious_Monarch@nile.com (Malicious Monarch)
  64. Subject: 3D Rotational examples - Help wanted
  65. Date: Tue,  5 Jul 94 14:39:38 MDT
  66. Organization: The Nile BBS
  67.  
  68.      I'm looking for some examples in creating simple three dimensional objects
  69. in C.  I've just started reading Michael Chen's article in issue 14 of develop,
  70. but I imagine there are some references to explain the use of the Graf3D library
  71. and perhaps even some more simplistic code to give a basic understanding of
  72. creating and drawing three dimensional objects.
  73.  
  74.      Please understand that I'm not concerned with a user interface at this
  75. point, just simple rendering code (ie making a cube and rotating it to give the
  76. illusion that it is a three dimensional object).  If someone could point toward
  77. some source code, or any literature (books, magazines, etc.) I would really
  78. really appreciate it.  Thanks...
  79.  
  80.  
  81. -Eric A. Drumbor-
  82.  
  83.      Opinions posted are of the user, not the administration.
  84.  
  85. +++++++++++++++++++++++++++
  86.  
  87. >From nick@pitt.edu ( nick.c )
  88. Date: Tue, 5 Jul 94 17:58:41 GMT
  89. Organization: University of Pittsburgh
  90.  
  91. In Article <0007E5C6.fc@nile.com>, Malicious_Monarch@nile.com (Malicious
  92. Monarch) wrote:
  93.  
  94. >     Please understand that I'm not concerned with a user interface at this
  95. >point, just simple rendering code (ie making a cube and rotating it to give the
  96. >illusion that it is a three dimensional object).  If someone could point toward
  97. >some source code, or any literature (books, magazines, etc.) I would really
  98. >really appreciate it.  Thanks...
  99.  
  100.   There is some code called "wireframeorama" (or something like that)
  101.     that's at both sumex and umich.  A couple of good books are:
  102.  
  103.    _Computer_Graphics_ 2nd ed by Hearn & Baker ISBN 0-13-161530-0
  104.  
  105.    _3D_Computer_Graphics_ 2nd ed by Alan Watt  ISBN 0-201-63186-5
  106.  
  107.   One general procedure is to imagine your "object" in 3D space 
  108.     (say with x,y,z co-ords centered around 0,0,0 to start),
  109.     then imagine an "observer" in the same space (say at x,y,z=0,0,100)
  110.     and a perpandicular plane between them (say at z= 70).
  111.  
  112.   Rotate, translate or do whatever to the object (working in cartesian it's
  113.     pretty easy - it's also handy to add a fourth parameter as a scaler
  114.     for xy&z - say t) then imagine vectors from the observer to each
  115.     point of your object (say the vertices of the cube).  The points
  116.     where your vectors intersect the plane are the points you want
  117.     to map to your graphics port.  Then just connect the dots in your
  118.     graphics port.  With wire frame, you don't have to worry 'bout 
  119.     which point is closer to the observer. 
  120.  
  121.   Hmmm... not the best explanation, but I'm kind of new to this too.
  122.     Check out those books (or anything around T385 in your library), 
  123.     it's a lot easier than it seems at first.  Luck,
  124.  
  125.                                             -- nick
  126.  
  127.  
  128.     
  129.  
  130.  
  131.    _/   _/  _/  _/_/_/   _/   _/  Sea Shells to C shells,  Waikiki to
  132.   _/_/ _/  _/  _/   _/  _/_/_/     the Internet, a wave, is a wave...
  133.  _/ _/_/  _/  _/       _/ _/
  134. _/   _/  _/   _/_/_/  _/   _/  CompSrv: 71232,766 I-Net: Nick@pitt.edu
  135.  
  136.  
  137. +++++++++++++++++++++++++++
  138.  
  139. >From cconstan@epdiv1.env.gov.bc.ca (Carl B. Constantine)
  140. Date: Wed, 06 Jul 1994 07:40:20 -0700
  141. Organization: Ministry of Environment, Lands & Parks
  142.  
  143. In article <nick.1123818761C@usenet.pitt.edu>, nick@pitt.edu ( nick.c ) wrote:
  144.  
  145. > In Article <0007E5C6.fc@nile.com>, Malicious_Monarch@nile.com (Malicious
  146. > Monarch) wrote:
  147. > >     Please understand that I'm not concerned with a user interface at this
  148. > >point, just simple rendering code (ie making a cube and rotating it to
  149. give the
  150. > >illusion that it is a three dimensional object).  If someone could
  151. point toward
  152. > >some source code, or any literature (books, magazines, etc.) I would really
  153. > >really appreciate it.  Thanks...
  154. >   There is some code called "wireframeorama" (or something like that)
  155. >     that's at both sumex and umich.  A couple of good books are:
  156.  
  157. [ snip ]
  158.  
  159. I have a good file (better than wireframeorama) that uses the Graph3D
  160. library and rotates and scales (I think) an object in 3D space.
  161.  
  162. e-mail me if you're interested.  I may post it (it's small)
  163.  
  164. -- 
  165. ========================================================================
  166. Carl B. Constantine                  B.C. Environment, Lands & Parks
  167. End-User Support Analyst             CCONSTAN@epdiv1.env.gov.bc.ca
  168.  PGP Key available if you finger: CCONSTAN@EUSACBC.env.gov.bc.ca
  169.  
  170. +++++++++++++++++++++++++++
  171.  
  172. >From kenlong@netcom.com (Ken Long)
  173. Date: Wed, 6 Jul 1994 15:32:47 GMT
  174. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  175.  
  176. On devtools.symantec.com there's a file called 3DGraphics (something like 
  177. that) which is a port to C from the old Lisa Pascal "Boxes" and 
  178. "BoxSpheres" programs sources.  Uses the Graf3D lib.
  179.  
  180. There are some rotaters on alt.sources.mac's home site.  One is a color 
  181. Graf3D thing written by jjcii@aol.com, as a learning tool for Graf3D.  
  182. One is a revival of some old code called "ROT-PSIG" in the snippets as 
  183. rotpsig2.  Lots of comments in this file, on the whole rotation thing 
  184. (non-Graf3D).
  185.  
  186. I've got 3 Pascal source (the C port doesn't run yet) for 
  187. rotating/animating 3D spheres and geometric shapes.  One came from AOL 
  188. and one from the CUMUG files.  Icosahedron6 is the latter.  Both use 
  189. "light sources" and thus shading.
  190.  
  191. -Ken-
  192.  
  193. ---------------------------
  194.  
  195. >From white@cs.sfu.ca (Steve &)
  196. Subject: CASE Tools for Macintosh
  197. Date: 29 Jun 1994 20:16:59 GMT
  198. Organization: Department of Mathematics and Statistics, Simon Fraser University
  199.  
  200. I've been looking into CASE tools for use with the Mac, and from a run
  201. through several issues of the Journal of Object Oriented Programming (JOOP)
  202. and Object Magazine (OM); I've found four.
  203.  
  204. This is a pretty crappy summary of what I found, but I hope to add to it.
  205.  
  206. If you know of or sell any others, please let me know and I'll post a better
  207. summary.  I'd quite like to hear of any experiences you have had with
  208. any Mac CASE tool, or of any review articles in MacUser or Mac World.
  209.  
  210. Cheers!
  211. ______________________________________________________________________________
  212. Vendor    Berard Software     Excel software  Iconix Software   Object Inter-
  213.           Engineering Inc                     Engineering       national, Inc
  214.  
  215. Tool      The Berard Object   MacAnalyist,    ObjectModeler     ObjecTool
  216.           and Class Specifier MacDesigner
  217.  
  218. Method    Berard, &c          ?               Rumb, &c          ?
  219.  
  220. platform  Mac "this summer",  Mac             Mac, others soon  all(!)
  221.           Win, OS/2
  222.           
  223. advert    p34 OM Sep 93       p45 OM Sep 93   p8 OM Dec 93      p6 OM Sept 93
  224.  
  225. review    p85 OM Sep 93                       p98 OM Nov 92     p94 JOOP v6#3
  226.  
  227. price $US 595                                                   995
  228.  
  229. code gen? Y                                                     Y
  230.  
  231. +++++++++++++++++++++++++++
  232.  
  233. >From nbhatia@netcom.com (Naresh Bhatia)
  234. Date: Sat, 2 Jul 1994 19:31:53 GMT
  235. Organization: MultiQuest Corporation
  236.  
  237. Steve & (white@cs.sfu.ca) wrote:
  238. : I've been looking into CASE tools for use with the Mac, and from a run
  239. : through several issues of the Journal of Object Oriented Programming (JOOP)
  240. : and Object Magazine (OM); I've found four.
  241.  
  242. : If you know of or sell any others, please let me know and I'll post a better
  243. : summary.
  244.  
  245. MultiQuest Corporation offers an object-oriented tool, called S-CASE, 
  246. that implements the Booch method. The Mac version is $249. I am attaching 
  247. a short summary for your information.
  248.  
  249. Naresh Bhatia
  250. MultiQuest Corporation
  251.  
  252.  
  253. S-CASE  is  a  multi-user  software  engineering  tool that supports the
  254. Booch method  of object-oriented  design. The  product allows developers
  255. to create models of their systems using graphical tools that  understand
  256. the  semantics  of  the  Booch  methodology.  C++  code can be generated
  257. automatically from  these models.  S-CASE is  one of  the first tools of
  258. its kind  to operate  on heterogeneous  networks of  PC, Macintosh,  and
  259. UNIX workstations.
  260.  
  261. S-CASE allows developers to experiment with many design approaches. High
  262. level designs  can be  created quickly  and later  refined by filling in
  263. details about class methods and attributes.
  264.  
  265. The tool's C++ code generation  encourages engineers to spend more  time
  266. in the critical analysis and  design phases and spend less  time writing
  267. code. C++  headers and  method stubs  are generated  directly from class
  268. diagrams. The engineer simply fills in the body of the methods.
  269.  
  270. S-CASE lets you  conduct on-line interactive  design reviews. Ideas  are
  271. quickly conveyed to colleagues and customers through concise full  color
  272. diagrams. Presentation  quality output  provides hard  copy handouts and
  273. documentation.
  274.  
  275. S-CASE stores data in a platform independent format allowing  multi-user
  276. access across different platforms.
  277.  
  278. Available immediately, S-CASE lists at:
  279.            $249  MS Windows and Macintosh
  280.            $995  Sun SPARC and HP 9000
  281.            (floating and site licenses also available)
  282.  
  283. Demos can be downloaded via  anonymous ftp at ftp.netcom.com. The  demos
  284. are under /pub/showcase.
  285.  
  286. The  Microsoft  Windows  demo  is  also  available  on CompuServe in the
  287. CASEFORUM. The demo is named  "showcase.zip" and is located in  the CASE
  288. library.
  289.  
  290. For further information please contact:
  291.  
  292.               ------------------------------------------
  293.                         MultiQuest Corporation
  294.                   1699 East Woodfield Road, Suite A-1
  295.                        Schaumburg, IL 60173, USA
  296.  
  297.                           Tel: (708) 240-5555
  298.                           Fax: (708) 240-5556
  299.                    Email: 72531.2510@compuserve.com
  300.               ------------------------------------------
  301.  
  302.  
  303. +++++++++++++++++++++++++++
  304.  
  305. >From Lars.Farm@nts.mh.se (Lars Farm)
  306. Date: Mon, 04 Jul 1994 08:38:06 +0100
  307. Organization: Mid Sweden University
  308.  
  309. In article <nbhatiaCsBvL5.HF0@netcom.com>, nbhatia@netcom.com (Naresh
  310. Bhatia) wrote:
  311.  
  312. > Steve & (white@cs.sfu.ca) wrote:
  313. > : I've been looking into CASE tools for use with the Mac, and from a run
  314. > : through several issues of the Journal of Object Oriented Programming (JOOP)
  315. > : and Object Magazine (OM); I've found four.
  316. > : If you know of or sell any others, please let me know and I'll post a better
  317. > : summary.
  318. > MultiQuest Corporation offers an object-oriented tool, called S-CASE, 
  319. > that implements the Booch method.
  320.  
  321. S-CASE? So they changed the name? I know it as Showcase and it is nice. Has
  322. editors for (new) Booch class diagrams and (new) Booch object interaction
  323. diagrams. Quite useful and usable! (even though the "crossplatform" nature
  324. shines through in some details.)
  325.  
  326. Lars
  327.  
  328. -- 
  329. Lars.Farm@nts.mh.se
  330.  
  331. ---------------------------
  332.  
  333. >From boris@world.std.com (Boris Levitin)
  334. Subject: Debugging an applet properly (AppleScript)
  335. Date: Tue, 5 Jul 1994 11:41:58 GMT
  336. Organization: The World @ Software Tool & Die
  337.  
  338. I'm writing a large AppleScript applet, and have two problems:
  339.  
  340. 1. I need to have a reliable way to refer to the applet's own
  341. parent folder, because that's where I store some configuration
  342. files the applet uses (I don't want to hardcode the path).
  343. "path to me" returns the path to the applet only when it's running
  344. as an applet. When it's run from inside Script Editor, "me" is
  345. interpreted to be Script Editor -- not the desirable effect. I'm
  346. tired of having to hardcode in a path every time I need to debug
  347. the applet; is there any way to say, path to this very script file?
  348.  
  349. 2. I have a large idle handler in my applet, and there doesn't seem
  350. to be a way to have Script Editor send an idle message to the applet
  351. when it's being debugged in it. Consequently, I have to comment out
  352. the on idle and end idle statements every time I debug. It's annoying,
  353. like item 1.
  354.  
  355. I would appreciate any suggestions.
  356.  
  357.  
  358. -- 
  359. Boris Levitin                                  WGBH Public Broadcasting, Boston
  360.                                    boris@world.std.com * boris_levitin@wgbh.org
  361.  
  362. +++++++++++++++++++++++++++
  363.  
  364. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  365. Date: Wed, 6 Jul 1994 16:22:59 GMT
  366. Organization: Apple Computer
  367.  
  368. Boris Levitin, boris@world.std.com writes:
  369. > "path to me" returns the path to the applet only when it's running
  370. > as an applet. When it's run from inside Script Editor, "me" is
  371. > interpreted to be Script Editor -- not the desirable effect. I'm
  372. > tired of having to hardcode in a path every time I need to debug
  373. > the applet; is there any way to say, path to this very script file?
  374.  
  375. Nope. AppleScript has no idea where the script it's executing is stored.
  376.  
  377. > 2. I have a large idle handler in my applet, and there doesn't seem
  378. > to be a way to have Script Editor send an idle message to the applet
  379. > when it's being debugged in it.
  380.  
  381. Not unless you explicitly say "idle" in your main body or 'on run' handler.
  382. The runtime environment of an applet is different than one being run by the
  383. editor, so it wouldn't really make sense for a script to be sent idle events
  384. while in the editor.
  385.  
  386. These things have both annoyed me too. But I couldn't think of a clean
  387. solution that didn't involve major reworking of the way scripts are edited in
  388. AS 1.X.
  389.  
  390. --Jens Alfke
  391.   jens_alfke@powertalk              Rebel girl, rebel girl,
  392.             .apple.com              Rebel girl you are the queen of my world
  393.  
  394. +++++++++++++++++++++++++++
  395.  
  396. >From jwbaxter@olympus.net (John W. Baxter)
  397. Date: Wed, 06 Jul 1994 12:19:45 -0700
  398. Organization: Internet for the Olympic Peninsula
  399.  
  400. In article <CsGttz.4o9@world.std.com>, boris@world.std.com (Boris Levitin)
  401. wrote:
  402.  
  403. > I'm writing a large AppleScript applet, and have two problems:
  404. > 1. I need to have a reliable way to refer to the applet's own
  405. > parent folder, because that's where I store some configuration
  406. > files the applet uses (I don't want to hardcode the path).
  407. > "path to me" returns the path to the applet only when it's running
  408. > as an applet. When it's run from inside Script Editor, "me" is
  409. > interpreted to be Script Editor -- not the desirable effect. I'm
  410. > tired of having to hardcode in a path every time I need to debug
  411. > the applet; is there any way to say, path to this very script file?
  412. >
  413. > 2. I have a large idle handler in my applet, and there doesn't seem
  414. > to be a way to have Script Editor send an idle message to the applet
  415. > when it's being debugged in it. Consequently, I have to comment out
  416. > the on idle and end idle statements every time I debug. It's annoying,
  417. > like item 1.
  418.  
  419. You might give Script Wizard a try (there is a demo [can't save scripts]
  420. version available at
  421.  
  422.   ftp://gaea.kgs.ukans.edu:applescript/demos/ScriptWiz.Demo.sit.hqx
  423.  
  424. (there's a press release "beside" the demo file in the same directory).
  425.  
  426. Note that I say "try":  I don't know whether "they" addressed the idle
  427. question or not.  Script Wizard is one of two OSA script editors recently
  428. announced, to fill the high-end of the editing services spectrum (it is
  429. said that Apple intentionally left that end open for third parties).  The
  430. other one isn't quite out yet.
  431.  
  432. Meanwhile...for debugging, I'd hard-code a path.  When the path to me
  433. returns a path to the Script Editor, have the run handler pass your action
  434. code the hard-coded path...otherwise have it pass the result from path to
  435. me.  Just remember not to give your script editor a clever name which
  436. breaks your test.
  437.    if (path to me) contains "Script Editor" then ...
  438.  
  439. --John
  440.  
  441. -- 
  442. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  443.    No hablo Intel.
  444.    jwbaxter@pt.olympus.net
  445.  
  446. ---------------------------
  447.  
  448. >From hoyer@cc.Helsinki.FI (P. Hoyer)
  449. Subject: GWorlds vs. Offscreens
  450. Date: 18 Jun 1994 02:03:40 +0300
  451. Organization: University of Helsinki
  452.  
  453. Once again, Hello netters!
  454.  
  455. Since it's almost 2 A.M. here in Finland and I'm waiting for the Spain
  456. vs. South-Korea soccer game to begin, I thought I'd ask a question that
  457. has long been on my mind.
  458.  
  459. I've been using regular old-style offscreen grafports (both 8-bit and
  460. b&w) for a few years now, and since I have reusable code to create these
  461. offscreens, I've never taken the trouble to really find out how GWorlds
  462. differ from these offscreens. Since I don't own the latest in Inside
  463. Macs, I can't look it up there.
  464.  
  465. So, what are the advantages of GWorlds? Is there really any reason to
  466. switch from offscreen grafports? I guess the main argument would be
  467. "they're easier to use" but since I already have working routines
  468. offscreens aren't a problem for me.
  469.  
  470. If this message is a bit unclear, it's only 'cause it's 02:04 in the
  471. morning and I'm tired as hell... :)
  472.  
  473. -P. Hoyer <hoyer@cc.helsinki.fi>
  474.  
  475. +++++++++++++++++++++++++++
  476.  
  477. >From Mark Hanrek <hanrek@cts.com>
  478. Date: Sat, 18 Jun 1994 13:08:48 GMT
  479. Organization: The Information Workshop
  480.  
  481. In article <2tta4c$585@kruuna.Helsinki.FI> P. Hoyer, hoyer@cc.Helsinki.FI
  482. writes:
  483.  
  484. > So, what are the advantages of GWorlds? Is there really any reason to
  485. > switch from offscreen grafports? I guess the main argument would be
  486. > "they're easier to use" but since I already have working routines
  487. > offscreens aren't a problem for me.
  488.  
  489. Well, as they say, "if it ain't broke, don't fix it".  If you are having
  490. good luck, then by all means don't change unless you need to.
  491.  
  492.  
  493. The advantages of GWorlds that come to mind include...
  494.  
  495. * Apple is responsible for the source code, not me. :)
  496.   ( this is my favorite advantage :)
  497.  
  498. * One simple call handles the creation of an entire GWorld, 
  499.   which includes the pixmap, grafport, and graphic device,
  500.   and color table.
  501.  
  502. * GWorlds handle aligning themselves with destination screen.
  503.  
  504. * Passing 0 for the bit depth causes GWorlds to pick up the 
  505.   attributes of the screen containing the majority of the 
  506.   passed global rectangle, automatically.
  507.  
  508. * After you create the GWorld, there are calls to conveniently 
  509.   obtain the pixmapHandle so you can lock it
  510.  
  511. * A single call (UpdateGWorld) will do whatever is necessary to 
  512.   ensure that the GWorld is totally optimized for fastest transfer
  513.   to the screen, including aligning its pixels with the screen's,
  514.   and making sure the source and destination color tables match.
  515.  
  516. * Pixels can be purged and restored, and also cached on a NuBus card
  517.   based graphics accelerator transparently.
  518.  
  519. There may be more advantages.
  520.  
  521.  
  522. The benefit of GWorlds handling and hiding all of the concerns 
  523. of graphic devices has allowed me to have the confidence that my
  524. software will work on any screen out there, and I didn't have to
  525. learn a single thing about the internals of graphic devices!
  526.  
  527. But as I say, the best part is that Apple maintains the code.
  528.  
  529. I am totally certain that there is at least one thing in their
  530. code that I would have never figured out.  :)
  531.  
  532. But also, if your's works fine, don't change it unless you must.
  533.  
  534. Spend your time, instead, on your struggle to get your palettes and
  535. color tables working properly.  :)
  536.  
  537. - ---------
  538.  
  539. When it comes to Palettes and Color Tables, there IS a big need
  540. for some help in this area.  There are almost no examples, and
  541. Forest Tanaka mentioned once that there won't be much new
  542. in this area, if anything, in Quickdraw/GX.
  543.  
  544. It took me days and days of trying every combination and permutation
  545. to zero in on what I am supposed to do, so that I am a courteous guy
  546. with respect to other applications and their color needs.  These 
  547. "interapplication issues" are not documented, nor is there example
  548. source code that has everything working together, and I have 
  549. scoured the earth in search of some.
  550.  
  551. BTW, in one's update event handler, you can include a call to
  552. UpdateGWorld.  If everything is fine, then it returns immediately.
  553.  
  554. If, however, the user moved into the background, and now the other 
  555. app's color table is in control, or the user changed the bit depth,
  556. then UpdateGWorld will either handle the situation for you ( and
  557. there will be a slight delay ) or you will get the signal that
  558. you must redraw your graphics into the GWorld because the user
  559. increased the bit depth ( since the color detail was lost when the
  560. user decreased the bit depth ).
  561.  
  562. Ensuring the color tables match has a BIG impact on performance. The
  563. difference is easily perceptible.
  564.  
  565. If you put a call to UpdateGWorld whenever the window is moved or
  566. resized, then you can rest assured your pixels will be automatically
  567. realigned, if necessary, for optimum performance as well.
  568.  
  569.  
  570. Hope this helps.
  571.  
  572. Mark Hanrek
  573.  
  574. +++++++++++++++++++++++++++
  575.  
  576. >From hoyer@cc.Helsinki.FI (P. Hoyer)
  577. Date: 18 Jun 1994 22:09:43 +0300
  578. Organization: University of Helsinki
  579.  
  580. >
  581. > But as I say, the best part is that Apple maintains the code.
  582. >
  583.  
  584. So what you essentially mean is that GWorlds are less likely to break
  585. when Apple decides to move stuff around and change stuff? This seems
  586. like a good reason to switch sooner or later...
  587.  
  588. >
  589. > But also, if your's works fine, don't change it unless you must.
  590. >  
  591. > Spend your time, instead, on your struggle to get your palettes and
  592. > color tables working properly.  :)
  593.  
  594. Well, since I've mostly written simple games which use the System
  595. palette, I haven't had to worry about colors really. Now, I'm making a
  596. little more serious game that will probably need a custom
  597. palette...hmmm, I think I ought to get some example code on GWorlds.
  598. Would anybody happen to have any good sample code?
  599.  
  600. I read about the Palette Manager in IM V (it's the latest I've got). Has
  601. it evolved much since the days of the MacII? ;)
  602.  
  603. -P. Hoyer <hoyer@cc.helsinki.fi>
  604.  
  605. +++++++++++++++++++++++++++
  606.  
  607. >From Mark Hanrek <hanrek@cts.com>
  608. Date: Sat, 18 Jun 1994 23:24:18 GMT
  609. Organization: The Information Workshop
  610.  
  611. In article <2tvgpn$ror@kruuna.Helsinki.FI> P. Hoyer, hoyer@cc.Helsinki.FI
  612. writes:
  613.  
  614. > I read about the Palette Manager in IM V (it's the latest I've got).
  615. > Has it evolved much since the days of the MacII? ;)
  616.  
  617. Not much. I think there are were some updating options added.
  618.  
  619.  
  620. As for examples, there are tons of them.  You will want to download files
  621. you find in the development source code areas of umich and sumex, in
  622. addition to ftp.apple.com.
  623.  
  624. DTS.lib is also an excellent reference.
  625.  
  626. Also, there are lots of examples all over the Developer CD, and a must
  627. have article is "Drawing in GWorlds for Speed and Versatility" from the
  628. May '92 issue of develop (includes source code).
  629.  
  630. Also, I have learned a lot from GMonde, and ResetColors, both by Forest
  631. Tanaka.
  632.  
  633. Hope this helps.
  634.  
  635. Mark Hanrek
  636.  
  637. +++++++++++++++++++++++++++
  638.  
  639. >From ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University)
  640. Date: 21 Jun 94 14:16:17 +1200
  641. Organization: University of Waikato, Hamilton, New Zealand
  642.  
  643. In article <CrLGIq.FFM@crash.cts.com>, Mark Hanrek <hanrek@cts.com> writes:
  644. >
  645. > The advantages of GWorlds that come to mind include...
  646. (lots of good ones omitted).
  647.  
  648. It is true. GWorlds take care of 90% of your needs. As one who started messing
  649. about with Color QuickDraw on one of the first Mac II's to hit New Zealand
  650. (back in 1987), it is *much* less fiddly to use GWorlds than to try to create
  651. your own GDevices.
  652.  
  653. However, there are a few things you can't do with GWorlds. For a start, you
  654. can't create a GWorld that does its drawing into a pre-existing pixmap.
  655.  
  656. In deference to my current enthusiasms, I should point out that the
  657. offscreen support in QuickDraw GX doesn't suffer from this problem. :-)
  658.  
  659. Lawrence D'Oliveiro                       fone: +64-7-856-2889
  660. Info & Tech Services Division              fax: +64-7-838-4066
  661. University of Waikato            electric mail: ldo@waikato.ac.nz
  662. Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
  663.  
  664. +++++++++++++++++++++++++++
  665.  
  666. >From Alex Kac <akac@delphi.com>
  667. Date: Fri, 1 Jul 94 23:33:06 -0500
  668. Organization: Delphi (info@delphi.com email, 800-695-4005 voice)
  669.  
  670. See if you can get the MacTech magazine from (I think...), April and May which
  671. have a complete tutorial on using GWorlds...
  672.  
  673. ---------------------------
  674.  
  675. >From Gordon Graber <gg4921s@Acad.Drake.Edu>
  676. Subject: GWorlds: When to lock pixels?
  677. Date: 6 Jul 1994 13:14:55 GMT
  678. Organization: Drake University
  679.  
  680. How Do All,
  681. Several questions about locking a GWorlds pixels:
  682. 1.  Must you lock the pixels to the GWorld if you have specified
  683. NoPurgePixels for the GWorld?
  684. 2.  If drawing and copyBitsing between several GWorlds in a loop, can one
  685. lock the pixels for each GWorld before the start of the loop and then
  686. unlock them after the loop is done executing?
  687. 3.  If you knew you were going to access several GWorlds often in a
  688. program, why not lock the pixels at the outset and unlock them when the
  689. program ends?
  690. 3a.  If this results in some kind of memory fragmentation, is there a way
  691. of optimizing this? ( like moveHi(); Lock(); ?)
  692. 4.  Why do you not have to lock the pixels to the main screen, or do you?
  693. 5.  Are there any conditions, possible exceptions above, under which one
  694. does not need to lock the pixels?
  695.  
  696. Thanks for any help,
  697.   Gordon Graber:  gg4921s@acad.drake.edu
  698.  
  699. +++++++++++++++++++++++++++
  700.  
  701. >From ctaylor@fox.nstn.ns.ca (Christian Taylor)
  702. Date: 6 Jul 1994 11:31:40 -0300
  703. Organization: Nova Scotia Technology Network
  704.  
  705. As far as I know, you should always lock the pixels when you're drawing. 
  706. Most drawing commands are safe and don't move memory, but things like
  707. PlotIcon do, and you'll lock up the computer if you leave the pixels
  708. unlocked.  When I create a GWrold, I usually lock the pixels right after
  709. and the unlock them in my de-init routine.
  710.  
  711. Christian
  712.  
  713.  
  714. +---------------------+----------------------------------+
  715. |  Christian Taylor   | Internet: ctaylor@fox.nstn.ns.ca |
  716. |The Party Palace BBS | CIS     : 71442,1161             |
  717. |   (902) 679-1218    | AOL     : Chris1020              |
  718. +---------------------+----------------------------------+
  719.  
  720. +++++++++++++++++++++++++++
  721.  
  722. >From al@crucible.powertools.com (Al Evans)
  723. Date: 6 Jul 94 14:35:09 GMT
  724. Organization: PowerTools, Austin, Texas
  725.  
  726. In article <2veaof$ru@dunix.drake.edu> gg4921s@Acad.Drake.Edu (Gordon Graber) writes:
  727.  
  728. >Several questions about locking a GWorlds pixels:
  729.  
  730. >1.  Must you lock the pixels to the GWorld if you have specified
  731. >NoPurgePixels for the GWorld?
  732.  
  733. Yes. NoPurgePixels simply keeps the pixels in memory. It doesn't keep
  734. them from moving. Incidentally, pixels are non-purgeable by default --
  735. unless you've made them purgeable on creation or later, they'll stay
  736. around.
  737.  
  738. >2.  If drawing and copyBitsing between several GWorlds in a loop, can one
  739. >lock the pixels for each GWorld before the start of the loop and then
  740. >unlock them after the loop is done executing?
  741.  
  742. Yes, unless memory is really tight and/or there is a lot of allocation
  743. and deallocation within the loop in question. 
  744.  
  745. >3.  If you knew you were going to access several GWorlds often in a
  746. >program, why not lock the pixels at the outset and unlock them when the
  747. >program ends?
  748.  
  749. Unless memory is really tight and/or (et cetera), this is a good thing
  750. to do. To the extent that you can do so, allocate all the memory you'll
  751. need at startup, and lock it down.
  752.  
  753. >3a.  If this results in some kind of memory fragmentation, is there a way
  754. >of optimizing this? ( like moveHi(); Lock(); ?)
  755.  
  756. I don't know whether this is "guaranteed", but in my experience
  757. LockPixels() already does a MoveHi().
  758.  
  759. >4.  Why do you not have to lock the pixels to the main screen, or do you?
  760.  
  761. Because they can't move. Even if you physically move your monitor, the
  762. graphics memory for that monitor stays in the same place:-)
  763.  
  764. >5.  Are there any conditions, possible exceptions above, under which one
  765. >does not need to lock the pixels?
  766.  
  767. You don't need to lock them if 1) you are operating on them entirely
  768. from within your own code, without calling ToolBox routines, and 2)
  769. if you don't do any memory allocation/deallocation from within that
  770. code. They will stay where they are unless there's a reason for them
  771. to move.
  772.                     --Al Evans--
  773. -- 
  774. Al Evans            |   Graphic Elements: A new standard for 
  775.                 |   high-performance interactive Macintosh graphics.
  776. al@crucible.powertools.com  |   Available from mac.archive.umich.edu
  777.                 |   /mac/misc/demo/graphicelementsdemo.sit.hqx
  778.  
  779. +++++++++++++++++++++++++++
  780.  
  781. >From Mark Hanrek <hanrek@cts.com>
  782. Date: Wed, 6 Jul 1994 15:33:56 GMT
  783. Organization: The Information Workshop
  784.  
  785. In article <454@crucible.powertools.com> Al Evans,
  786. al@crucible.powertools.com writes:
  787.  
  788. >>4. Why do you not have to lock the pixels to the main screen ?
  789. >
  790. > Because they can't move. Even if you physically move your monitor, the
  791. > graphics memory for that monitor stays in the same place :-)
  792. >
  793.  
  794. Al,
  795.  
  796. You crack me up! :) :) :)
  797.  
  798. Mark
  799.  
  800. ---------------------------
  801.  
  802. >From tfullert@bottom.magnus.acs.ohio-state.edu (tfullert)
  803. Subject: How do you write TIFFs?
  804. Date: 6 Jul 1994 17:32:44 GMT
  805. Organization: The Ohio State University
  806.  
  807. Greetings:
  808.  
  809. I am developing an application where I must export graphics as TIFFs. 
  810. Does any free source exist for this exist?  Where might I find it?
  811.  
  812. Thanks.
  813.  
  814. Tim
  815.  
  816. +++++++++++++++++++++++++++
  817.  
  818. >From Mark Hanrek <hanrek@cts.com>
  819. Date: Thu, 7 Jul 1994 01:47:33 GMT
  820. Organization: The Information Workshop
  821.  
  822. Subject: How do you write TIFFs?
  823. From: tfullert, tfullert@bottom.magnus.acs.ohio-state.edu
  824. Date: 6 Jul 1994 17:32:44 GMT
  825. In article <2veprs$gh2@charm.magnus.acs.ohio-state.edu> tfullert,
  826. tfullert@bottom.magnus.acs.ohio-state.edu writes:
  827.  
  828. > Greetings:
  829. >
  830. > I am developing an application where I must export graphics as TIFFs. 
  831. > Does any free source exist for this exist?  Where might I find it?
  832. >
  833. > Thanks.
  834. >
  835. > Tim
  836.  
  837.  
  838. Tim,
  839.  
  840. I suggest you use Archie, because it will easily pull up trillions of
  841. places where TIFF source code can be found.  This is usually a package by
  842. Sam Leffler for unix systems.
  843.  
  844. Also, the URT (Utah Raster Toolkit) has TIFF writing code. ( University
  845. of Utah :).
  846.  
  847. A package called MegaTIFF can be found on AppleLink ( I think that is Sam
  848. Leffler's package kinda ported to MPW ).
  849.  
  850. You will also want to look on CompuServe, which is where the "Aldus
  851. Developer Desk" lives, and example source code can be found there, in
  852. addition to the test suite of TIFF pictures.
  853.  
  854. You will also want to definitely have your own copy of the TIFF 6.0
  855. Specification.  Get it and print it from the PostScript formatted
  856. version.  It is a beautiful and well-written document that will clarify
  857. many things for you. ( wierd, huh? :)
  858.  
  859. This document can be found on umich, and possibly sumex.
  860.  
  861. The other things I can think of only decode TIFF, and I've mentioned all
  862. the good stuff anyway.
  863.  
  864.  
  865. Hope this helps.
  866.  
  867. Mark Hanrek
  868.  
  869. +++++++++++++++++++++++++++
  870.  
  871. >From rgc3679@halcyon.com (Bob Carpenter)
  872. Date: Wed, 06 Jul 1994 20:34:28 -0800
  873. Organization: Northwest Nexus Inc.
  874.  
  875. In article <2veprs$gh2@charm.magnus.acs.ohio-state.edu>,
  876. tfullert@bottom.magnus.acs.ohio-state.edu (tfullert) wrote:
  877.  
  878. > Greetings:
  879. > I am developing an application where I must export graphics as TIFFs. 
  880. > Does any free source exist for this exist?  Where might I find it?
  881.   At SGI's anonymous ftp sit (ftp.sgi.com) in directory: graphics/tiff
  882.   you'll find much information and source code for working with TIFFs.
  883.   You'll also find the latest version of the TIFF specification (6).
  884.  
  885.   You may also want to subscribe to the tiff mailing list by sending
  886.   the word subscribe in the body of a message to:
  887.  
  888.     majordomo@whizzer.wpd.sgi.com
  889.  
  890. -- 
  891. --BobC
  892.  
  893. ---------------------------
  894.  
  895. >From tzs@u.washington.edu (Tim Smith)
  896. Subject: How to tell Energy Saver to turn the monitor on or off
  897. Date: 4 Jul 1994 13:35:09 GMT
  898. Organization: University of Washington School of Law, Class of '95
  899.  
  900. A few months ago, I spent a while disassembling Apple's Energy Saver
  901. control panel to figure out how it worked.  I needed to know this
  902. because I wanted to make it work for me under A/UX.  That effort was
  903. a success, allowing me to create an extension, Energy Beaver, that
  904. loads before Energy Saver under A/UX, and diddles a few things so
  905. that Energy Saver will be happy.  (Energy Beaver, plus source code,
  906. is available on ftp.u.washington.edu, in public/tzs, if anyone wants
  907. it).
  908.  
  909. A couple of weeks ago, someone asked me via email how one interfaces
  910. to Energy Saver.  They wanted to add Energy Saver support to a screen
  911. saver they were working on.  It occured to me that this might be of
  912. interest to others, so I decided to post a copy of my response here.
  913. That is appended at the end of this post.
  914.  
  915. Apple's Energy Saver actually consists of three components.  A
  916. driver that patches into the video driver and actually does the
  917. hardware manipulation (this driver is contained in an INIT
  918. resource, so you won't find a DRVR in the Energy Saver file),
  919. an INIT that is basically a screen saver that calls the driver
  920. when it is time to blank the screen or unblank it, and a CDEV
  921. that provides the interface.  When you turn Energy Saver off
  922. from the CDEV, all you are really doing is telling the screen
  923. saver INIT to turn off.  The driver is still active, and can
  924. be called from other software to turn the monitor off and on.
  925.  
  926. - --------- copy of letter follows --------
  927.  
  928. Hello;
  929.  
  930.     I've looked at the Energy Saver disassembly, and done a little
  931. experimenting.  Here's the information you need, I think.
  932.  
  933. 1. Determining if Energy Saver supports a particular video card.
  934.  
  935. Issue a status call to the driver, with csCode=11, and csParam containing
  936. a pointer to a data area of 6 bytes.  I don't think it matters what you
  937. place in this data area, but Apple places zeros there, so I'd do that
  938. too.  If this control call does not return an error, then the Energy
  939. Saver driver is installed for that monitor.
  940.  
  941. 2. To enter Energy Saving mode.
  942.  
  943. Step through the graphics device list.  For each device, determine if
  944. Energy Saver is installed for that device using that above test.  For
  945. each that it is, do a control call with csCode=11 (that's decimal 11,
  946. not hex 11), and csParam containing a pointer to a data area of six
  947. bytes.  In that six bytes, place the following: 0x01, 0x01, 'H', 'A',
  948. 'L', ' '.
  949.  
  950. 3. To exit Energy Saving mode.
  951.  
  952. This is similar to entering Energy Saving mode, except that those first
  953. two bytes of the six byte data area should be 0x00 and 0x00 instead of
  954. 0x01 and 0x01.
  955.  
  956. After you've turned everything on, for each monitor do a status call
  957. with csCode=11, and csParam containing a pointer to six bytes of data.
  958. Fill out that data area with 0x00, 0x00, 'H', 'A', 'L', ' ' before
  959. doing the call.  After the status call, check byte 1 of the six byte
  960. data area (numbered from 0).  If that byte ANDed with 0x80 is non-zero,
  961. then do the following:
  962.  
  963.         short temp = (*g)->gdMode & 0xffff;
  964.         (*g)->gdMode = 0;
  965.         SetDepth(g,temp,0,0);
  966.  
  967. where g is a handle to the GDevice record for the monitor.
  968.  
  969. After you've set the depth on all the monitors that need it, call
  970. DrawMenuBar.
  971.  
  972. 4. Some observations.
  973.  
  974. I don't think it matters whether or not the 'HAL ' stuff is placed in
  975. the six byte data area in the control and status calls.  I didn't
  976. notice anything that checked for this in the driver that handles these
  977. calls when I disassembled them.
  978.  
  979. Energy Saving mode seems to scramble some of the VRAM.  When it comes
  980. out of Energy Saving mode, there are random colored pixels scattered
  981. around.  That business with SetDepth seems to be to get everyone to
  982. update the screen.  If you are doing this from a screen saver, presumably
  983. you will already be making everyone redraw, so you probably don't need
  984. this.
  985.  
  986. The status call seems to modify the first two bytes of the six byte data
  987. area pointed to be csParam.  I do not know what the significance of byte 1
  988. is, other than it seems to contain that flag that tells if the monitor
  989. needs to have the screen redrawn to clean up the garbage.  Byte 0 seems
  990. to get written with 0x00 if the monitor is not in Energy Saving mode,
  991. and 0xFF if it is.  Apple's software does not seem to make use of this,
  992. so it is not clear that it is safe to rely on it.
  993.  
  994. 5. Sample code.
  995.  
  996. Here is a simple program fragment that enters Energy Saving mode, waits for
  997. a mouse click, and then leaves Energy Saving mode.
  998.  
  999.  
  1000.     CntrlParam    c;
  1001.     GDHandle    g;
  1002.     OSErr        e;
  1003.     short        res[3];        // the six byte data area
  1004.     
  1005.     //
  1006.     // We'll just do the first screen
  1007.     //
  1008.     g = GetDeviceList();
  1009.     
  1010.     c.ioCRefNum = (*g)->gdRefNum;
  1011.     c.csCode = 11;
  1012.     res[0] = 0; res[1] = 0; res[2] = 0;
  1013.     *(short **)(&c.csParam[0]) = &res[0];
  1014.     c.ioCompletion = 0;
  1015.     e = PBStatus( (ParmBlkPtr)&c, 0 );
  1016.     if ( e )
  1017.     {
  1018.         cout << "Energy Saver not supported!" << endl;
  1019.         return;
  1020.     }
  1021.  
  1022.     //
  1023.     // Turn monitor off
  1024.     //
  1025.     c.ioCRefNum = (*g)->gdRefNum;
  1026.     c.csCode = 11;
  1027.     res[0] = 0x0101; res[1] = 'HA'; res[2] = 'L ';
  1028.     *(short **)(&c.csParam[0]) = &res[0];
  1029.     c.ioCompletion = 0;
  1030.     e = PBControl( (ParmBlkPtr)&c, 0 );
  1031.     
  1032.     //
  1033.     // Pause until the mouse is clicked
  1034.     //
  1035.     while ( ! Button() )
  1036.         ;
  1037.     while ( Button() )
  1038.         ;
  1039.  
  1040.     //
  1041.     // Turn monitor back on
  1042.     //
  1043.     c.ioCRefNum = (*g)->gdRefNum;
  1044.     c.csCode = 11;
  1045.     res[0] = 0x0000; res[1] = 'HA'; res[2] = 'L ';
  1046.     *(short **)(&c.csParam[0]) = &res[0];
  1047.     c.ioCompletion = 0;
  1048.     e = PBControl( (ParmBlkPtr)&c, 0 );
  1049.     
  1050.     //
  1051.     // See if we need to set the depth to clean up the garbage
  1052.     //
  1053.     c.ioCRefNum = (*g)->gdRefNum;
  1054.     c.csCode = 11;
  1055.     res[0] = 0; res[1] = 'HA'; res[2] = 'L ';
  1056.     *(short **)(&c.csParam[0]) = &res[0];
  1057.     c.ioCompletion = 0;
  1058.     e = PBStatus( (ParmBlkPtr)&c, 0 );
  1059.     
  1060.     if ( res[0] & 0x0080 )
  1061.     {
  1062.         short temp = (*g)->gdMode & 0xffff;
  1063.  
  1064.         (*g)->gdMode = 0;
  1065.         SetDepth(g,temp, 0, 0 );
  1066.     }
  1067.     
  1068.  
  1069. ---------------------------
  1070.  
  1071. >From altitude@umich.edu (Alex Tang)
  1072. Subject: Newbie Gworld questions.
  1073. Date: 3 Jul 1994 14:11:22 GMT
  1074. Organization: University of Michigan
  1075.  
  1076. Hi folks.  I've got some pretty newbie'ish questions about Gworlds...
  1077.  
  1078. First, i haven't been able to find a good explaination about what they're
  1079. used for.  From the various bits of info that I've picked up, they
  1080. comprise of a lot of different graphics devices and tools (i.e. offscreen
  1081. drawing).  Is that right?  Is the main purpose for them so that offscreen
  1082. drawing is easier?
  1083.  
  1084. The main reason i'm asking is that I'm trying to write a small,
  1085. rudamentary graphics app.  It's something to teach me how to do
  1086. mac programming.  Basically, it's supposed be able to open some windows,
  1087. do some drawing into the wndows, and save the file as a PICT.  I've hit a
  1088. minor roadblock trying to figure out how where to draw the stuff and be
  1089. able to do updates on it.  At first, I thought I could draw directly to
  1090. the window, but that didn't work.  I'm trying to figure out if i need to
  1091. use gworlds for this (and i guess i should learn about them anyway).  
  1092.  
  1093. Well, Thanx for any insight that is provided.
  1094.  
  1095. ...alex...
  1096.  
  1097. --
  1098.     Alex Tang      |     UM-SNRE     |       UM-ITD/US Consultant II
  1099. ALTITUDE@UMICH.EDU |     Student     | http://www.snre.umich.edu/~altitude
  1100.   PGP via finger.  |  Systems Admin  | "Life's a game.  
  1101. This space for rent| Comp.Consut III |  play for fun, and play with Honor."
  1102.  
  1103. +++++++++++++++++++++++++++
  1104.  
  1105. >From gurgle@netcom.com (Pete Gontier)
  1106. Date: Mon, 4 Jul 1994 01:06:54 GMT
  1107. Organization: cellular
  1108.  
  1109. altitude@umich.edu (Alex Tang) writes:
  1110.  
  1111. >Is the main purpose for (GWorlds) so that offscreen drawing is easier?
  1112. >The main reason i'm asking is that I'm trying to write a small,
  1113. >rudamentary graphics app. ...it's supposed be able to open some
  1114. >windows, do some drawing into the wndows, and save the file as a PICT.
  1115.  
  1116. The question should be then, whether this drawing is going to require
  1117. you to use CopyBits. CopyBits is the routine used to shove bit maps and
  1118. pixel maps around in memory, on-screen and off-screen and in between
  1119. the two. You need it only if you need to do some image processing which
  1120. occurs as a side-effect of calls to CopyBits (colorizing bitmaps,
  1121. dithering, blending pixel maps, etc.) *or* you're trying to do some
  1122. updating which needs to be smooth or animated.
  1123.  
  1124. If the answer to this sort of question is "no", then don't bother with
  1125. GWorlds. Stick with Pictures. They're easier to deal with and they can
  1126. be translated almost directly into PICT files (such files are 512 bytes
  1127. of 0 followed by the contents of a PicHandle).
  1128.  
  1129. >I've hit a minor roadblock trying to figure out how where to draw the
  1130. >stuff and be able to do updates on it. At first, I thought I could draw
  1131. >directly to the window, but that didn't work...
  1132.  
  1133. Yes, and I understand the problem. Pictures will allow you to get around
  1134. this quite nicely, and in general in less memory than GWorlds, too.
  1135.  
  1136. Happy reading!
  1137. -- 
  1138.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  1139.  
  1140.  "...someone not acquainted with the Christian mythology of the
  1141.  Crucifixion might consider a Crucifix to be a particularly sadistic
  1142.  piece of erotica... We of the ACLU will continue to defend your right to
  1143.  worship such objects if it pleases you." -- Gregory J. Wageman
  1144.  
  1145. +++++++++++++++++++++++++++
  1146.  
  1147. >From Mark Hanrek <hanrek@cts.com>
  1148. Date: Mon, 4 Jul 1994 21:03:07 GMT
  1149. Organization: The Information Workshop
  1150.  
  1151. In article <2v6gua$62j@lastactionhero.rs.itd.umich.edu> Alex Tang,
  1152. altitude@umich.edu writes:
  1153.  
  1154. > Hi folks.  I've got some pretty newbie'ish questions about Gworlds...
  1155. >
  1156. > First, i haven't been able to find a good explaination about what
  1157. they're
  1158. > used for.  From the various bits of info that I've picked up, they
  1159. > comprise of a lot of different graphics devices and tools (i.e.
  1160. offscreen
  1161. > drawing).  Is that right?  Is the main purpose for them so that
  1162. offscreen
  1163. > drawing is easier?
  1164. >
  1165. > The main reason i'm asking is that I'm trying to write a small,
  1166. > rudamentary graphics app.  It's something to teach me how to do
  1167. > mac programming.  Basically, it's supposed be able to open some windows,
  1168. > do some drawing into the wndows, and save the file as a PICT.  I've hit
  1169. a
  1170. > minor roadblock trying to figure out how where to draw the stuff and be
  1171. > able to do updates on it.  At first, I thought I could draw directly to
  1172. > the window, but that didn't work.  I'm trying to figure out if i need to
  1173. > use gworlds for this (and i guess i should learn about them anyway).  
  1174. >
  1175. > Well, Thanx for any insight that is provided.
  1176. >
  1177. > ...alex...
  1178.  
  1179.  
  1180. Alex,
  1181.  
  1182. Here is the answer to all of your questions at once.  It is the answer
  1183. you were looking for...
  1184.  
  1185. As an illustrative example, let's say your application has one window
  1186. which contains an XY bar graph of some data you have.  This graph would,
  1187. of course, have the XY lines, the tick marks, the numbers for the tick
  1188. marks, the titles, the data bars, etc, all made up of a series of
  1189. QuickDraw calls, such as MoveTo, LineTo, FrameRect, PaintRect,
  1190. DrawString, etc.
  1191.  
  1192.  
  1193. - --- Setting up your application
  1194.  
  1195. All "imaging" for this window should happen ONLY in response to the
  1196. "update" event that is sent to this window.  Period.  Your update event
  1197. handler should look something like this...
  1198.  
  1199.   void DoUpdateEvent( WindowPtr  theWindow )
  1200.   {
  1201.      BeginUpdate( theWindow );
  1202.      DrawWindowContents( theWindow );
  1203.      EndUpdate( theWindow );
  1204.   }
  1205.  
  1206. The routine "DrawWindowContents" should draw EVERYTHING that appears in
  1207. your window whenever it is called regardless.  This is the correct thing
  1208. to do.  A window should always start life this way.  Do NOT put any calls
  1209. to draw this window anywhere else in your software.  No exceptions.
  1210.  
  1211. When the window is created, an update event will automatically be sent to
  1212. it. Convenient. 
  1213.  
  1214. And if there is some reason you need to update a certain area of your
  1215. window (and the system didn't ask you to), you can do this by
  1216. "invalidating" the desired area of your window, by calling InvalRect().
  1217. This triggers an update event to have that area of the window "cleaned
  1218. up".
  1219.  
  1220. In your update event handler, you must use the BeginUpdate and EndUpdate
  1221. calls, allowing you to take advantage of the Window Manager, which keeps
  1222. track of which part of your window actually needs to be re-drawn. ( The
  1223. update region ).
  1224.  
  1225. Your DrawWindowContents() routine will blindly draw everything to this
  1226. window, but the OS will automatically cut short any QuickDraw calls that
  1227. draw to areas of the window that do not actually need updating.
  1228.  
  1229. Even with this automatic built-in optimization, if you have a very
  1230. complex drawing, you will find that updating the window can be sluggish,
  1231. and you can see all the individual elements being re-drawn, as you do can
  1232. in, say, a complex MacDraw or Canvas drawing.
  1233.  
  1234. This is where GWorlds come in handy...
  1235.  
  1236.  
  1237. - --- Incremental Improvement #1
  1238.  
  1239. In response to the update event, create a GWorld the same size as your
  1240. window, draw the whole image into the GWorld instead, and then draw the
  1241. entire GWorld to the window all at once using CopyBits, then dispose of
  1242. the GWorld. 
  1243.  
  1244. This makes it so the user does not see all the individual elements being
  1245. redrawn.
  1246.  
  1247. This is what happens when you do a "lock screen" then an "unlock screen"
  1248. in HyperCard.
  1249.  
  1250. This does not, however, eliminate the time it takes to draw all the
  1251. individual elements. If you were to, say, move another window that
  1252. overlaps the bar graph window by just one pixel, an update event would,
  1253. of course, be sent to your bar graph window, and it would spend the time
  1254. redrawing the scores of things that make up the image.  To help optimize
  1255. that, we can take the usage of our GWorld a step further...
  1256.  
  1257.  
  1258. - --- Incremental Improvement #2
  1259.  
  1260. When you create your window for the first time, also create a GWorld the
  1261. same size as your window, and have DrawWindowContents() draw its image
  1262. into the GWorld instead, once only, to "prep" the GWorld.
  1263.  
  1264. Then from that point on, in response to an update event, simply use
  1265. CopyBits to transfer the ENTIRE GWorld to the entire window.  The Window
  1266. Manager will only allow the needed areas to actually be transferred, and
  1267. you will now have the most efficient and optimal way of handling the
  1268. imaging of window contents.
  1269.  
  1270. Your window updating will now be instantaneous, and there will be no
  1271. sluggishness.
  1272.  
  1273. When you close the window, dispose of the GWorld too.
  1274.  
  1275.  
  1276. - --- Important Note
  1277.  
  1278. This explanation is a lot like putting you in a row boat and giving you a
  1279. starting push in the direction of that little reef offshore you want to
  1280. get to.  
  1281.  
  1282. You do not need to know all about boats, all about the ocean, and all
  1283. about propulsion in order to make it to that little reef successfully. 
  1284. You also do not need to know at this time how to handle things
  1285. differently if you were hypothetically put in an outrigger instead.
  1286.  
  1287. Don't allow yourself or others to unnecessarily complicate things.  Take
  1288. this simple push and go with it, and you will quickly "get it".
  1289.  
  1290.  
  1291. - --- Following Advice
  1292.  
  1293. Mark my words.  If you put drawing-to-window code anywhere else than in
  1294. your update handler, you will find that a good chunk of your code, and
  1295. the time it took to develop it, ends up being spent on compensating for
  1296. the problems and side-effects that were created as a result of not
  1297. following this sage advice.
  1298.  
  1299. I made this mistake myself when I first started, and paid a hefty price
  1300. for it, too.  Hopefully you can avoid the waste of repeating this common
  1301. (and undocumented) programming error.
  1302.  
  1303.  
  1304. Hope this helps!
  1305.  
  1306. Mark Hanrek
  1307. The Information Workshop
  1308.  
  1309.  
  1310. - ----------------------------------
  1311.  
  1312. P.S.  The other undocumented programming error waiting to eat you is
  1313. mixing the use of GetPort/SetPort and GetGWorld/SetGWorld in the same
  1314. application.  
  1315.  
  1316. The minute you start working with GWorlds, eliminate all uses of
  1317. GetPort/SetPort from your application, changing them all to the more
  1318. modern GetGWorld/SetGWorld.
  1319.  
  1320. Ouch!
  1321.  
  1322. +++++++++++++++++++++++++++
  1323.  
  1324. >From kenlong@netcom.com (Ken Long)
  1325. Date: Tue, 5 Jul 1994 17:04:15 GMT
  1326. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1327.  
  1328. For more reading on GWorlds, get "Programming QuickDraw" by Surovell, 
  1329. Hall and Othmer.
  1330.  
  1331. For an example of an application comparison WITHOUT and WITH GWorlds 
  1332. (GWorld added by Mark Hanrek) get NuCube and NewCube C source demos. (I 
  1333. believe they are on sumex, in a file called "ThreePointPlotters" or 
  1334. "WireFrameORama").
  1335.  
  1336. There are excellent, comprehenhive examples of GWorld C sources on 
  1337. ftp.apple.com (GWorld Drawing - not an app. source, but several routines) 
  1338. and "GWorlds" from devtools.symantec.com - source for a complete application.
  1339.  
  1340. Of course, there are many more, too.  cicnAnimDemo uses GWorlds.
  1341.  
  1342. I was told, by a downloader of NuCude (which Mark contributed to), that 
  1343. he really gained a lot of understanding of them from the source.  Well, 
  1344. Mark understands them - that's why.
  1345.  
  1346. -Ken-
  1347.  
  1348. ---------------------------
  1349.  
  1350. >From brewster@enc.org (Dave Brewster)
  1351. Subject: Patching Trap ExitToShell using UniversalProcPtr's
  1352. Date: 5 Jul 1994 01:38:45 -0400
  1353. Organization: Eisenhower National Clearinghouse
  1354.  
  1355. How does one go about doing this on the PPC.  I've tried:
  1356.    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1357. where MyExitToShellUPP = 
  1358.    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1359. GetCurrentISA());
  1360.  
  1361. I figured this would be correct, but it dies a violent death!
  1362.  
  1363. Is the kCStackBased parameter wrong?  My routine doesn't take any
  1364. parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1365. return anything either.
  1366.  
  1367. My ExitToShell routine looks like:
  1368.  
  1369. void MyExitToShell (void)
  1370. {
  1371.    SetCurrentA5();
  1372.    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1373.    EndNNTP();
  1374.    NetTerm();
  1375.    ExitToShell();
  1376. }
  1377.  
  1378. What's the deal,
  1379.  
  1380. Dave
  1381.  
  1382. +++++++++++++++++++++++++++
  1383.  
  1384. >From stevec@jolt.mpx.com.au (Stephen F Coy)
  1385. Date: 5 Jul 1994 13:52:33 GMT
  1386. Organization: Microplex Pty Ltd
  1387.  
  1388. Dave Brewster (brewster@enc.org) wrote:
  1389. : How does one go about doing this on the PPC.  I've tried:
  1390. :    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1391. : where MyExitToShellUPP = 
  1392. :    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1393. : GetCurrentISA());
  1394.  
  1395. : I figured this would be correct, but it dies a violent death!
  1396.  
  1397. : Is the kCStackBased parameter wrong?  My routine doesn't take any
  1398. : parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1399. : return anything either.
  1400.  
  1401. : My ExitToShell routine looks like:
  1402.  
  1403. : void MyExitToShell (void)
  1404. : {
  1405. :    SetCurrentA5();
  1406. :    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1407. :    EndNNTP();
  1408. :    NetTerm();
  1409. :    ExitToShell();
  1410. : }
  1411.  
  1412. If you use the standard C library function "atexit" instead you would not 
  1413. have to worry about all this stuff.
  1414.  
  1415. In general, you should avoid patching traps. Most of the time it is 
  1416. not necessary.
  1417.  
  1418.  
  1419.  : What's the deal,
  1420.  
  1421. : Dave
  1422.  
  1423. Steve Coy
  1424. Resolve Software (WA) P/L
  1425.  
  1426.  
  1427. +++++++++++++++++++++++++++
  1428.  
  1429. >From wdh@netcom.com (Bill Hofmann)
  1430. Date: Tue, 5 Jul 1994 16:11:42 GMT
  1431. Organization: Fresh Software
  1432.  
  1433. In article <199407050538.FAA08919@charm.magnus.acs.ohio-state.edu>,
  1434. brewster@enc.org (Dave Brewster) wrote:
  1435.  
  1436. > How does one go about doing this on the PPC.  I've tried:
  1437. >    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1438. > where MyExitToShellUPP = 
  1439. >    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1440. > GetCurrentISA());
  1441. > I figured this would be correct, but it dies a violent death!
  1442. > Is the kCStackBased parameter wrong?  My routine doesn't take any
  1443. > parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1444. > return anything either.
  1445. > My ExitToShell routine looks like:
  1446. > void MyExitToShell (void)
  1447. > {
  1448. >    SetCurrentA5();
  1449. >    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1450. >    EndNNTP();
  1451. >    NetTerm();
  1452. >    ExitToShell();
  1453. > }
  1454. Well, with few exceptions, the entire toolbox is either kPascalStackBased
  1455. or kRegisterBased.  So you have two (well, 1.5) problems:
  1456.  
  1457. MyExitToShellUPP = NewRoutineDescriptor((ProcPtr)MyExitToShell,
  1458.                         kPascalStackBased, GetCurrentISA());
  1459. ...
  1460. pascal void MyExitToShell(void)
  1461. {
  1462. ...
  1463. }
  1464.  
  1465. I say 1.5 because a pascal void ... (void) is pretty much the same as a
  1466. void ... (void), but better to be compulsive than sorry.  I assume that
  1467. you init gOldExitToShellTrapAddress.  Does your code (minus the
  1468. NewRoutineDescriptor()) work on 040 machines?
  1469.  
  1470. -- 
  1471. Bill Hofmann                                   wdh@netcom.com
  1472. Fresh Software and Instructional Design        voice: +1 510 524 0852
  1473. 1640 San Pablo Ave #C, Berkeley CA 94702 USA   fax:   +1 510 524 0853
  1474.  
  1475. +++++++++++++++++++++++++++
  1476.  
  1477. >From kbell@cs.utexas.edu (Kevin Bell)
  1478. Date: Tue, 05 Jul 1994 18:34:35 -0600
  1479. Organization: The University of Texas at Austin, Austin, Texas
  1480.  
  1481. In article <199407050538.FAA08919@charm.magnus.acs.ohio-state.edu>,
  1482. brewster@enc.org (Dave Brewster) wrote:
  1483.  
  1484. > How does one go about doing this on the PPC.  I've tried:
  1485. >    SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1486. > where MyExitToShellUPP = 
  1487. >    NewRoutineDescriptor((ProcPtr)(MyExitToShell), kCStackBased,
  1488. > GetCurrentISA());
  1489. > I figured this would be correct, but it dies a violent death!
  1490. > Is the kCStackBased parameter wrong?  My routine doesn't take any
  1491. > parameters so I'm not or'ing this with anything.  Oh yea, and it doesn't
  1492. > return anything either.
  1493. > My ExitToShell routine looks like:
  1494. > void MyExitToShell (void)
  1495. > {
  1496. >    SetCurrentA5();
  1497. >    SetToolTrapAddress(gOldExitToShellTrapAddress, _ExitToShell);
  1498. >    EndNNTP();
  1499. >    NetTerm();
  1500. >    ExitToShell();
  1501. > }
  1502. > What's the deal,
  1503. > Dave
  1504.  
  1505. Here's the code I used to do the same thing
  1506.  
  1507. // KMB: ExitToShell UPP Info
  1508.  
  1509. static UniversalProcPtr gOldExitToShellTrapAddress;
  1510.  
  1511. enum {
  1512.     exitToShellProcInfo = kPascalStackBased
  1513. };
  1514.  
  1515. static void PatchExitToShell (void)
  1516. {
  1517.     UniversalProcPtr MyExitToShellUPP =
  1518.         NewRoutineDescriptor((ProcPtr)MyExitToShell,
  1519.                          exitToShellProcInfo,
  1520.                          GetCurrentISA());
  1521.     gOldExitToShellTrapAddress = GetToolTrapAddress(_ExitToShell);
  1522.     SetToolTrapAddress(MyExitToShellUPP, _ExitToShell);
  1523. }
  1524.  
  1525.  
  1526.     BTW, thanks for asking this question. When I tried to open the source
  1527. code with my PowerMac compiled NewsWatcher, I discovered some errors with
  1528. my standard file UPP stuff. IMHO, universal procedure pointers have a
  1529. serious problem in that the compiler cannot do any type checking like it
  1530. could for regular function pointers. In my case, I was creating a
  1531. FileFilterUPP where a ModalFilterUPP was needed.
  1532.  
  1533. -- 
  1534. Kevin Bell
  1535. kbell@cs.utexas.edu
  1536.  
  1537. ---------------------------
  1538.  
  1539. >From gtodorov@ralph.cs.haverford.edu (Gordan Todorovac)
  1540. Subject: Porting from Unix to Mac - Summary
  1541. Date: 1 Jul 1994 17:29:34 GMT
  1542. Organization: Haverford College Computer Science Department
  1543.  
  1544. Thanks to all who replied. Here is the content of three replies which summarize
  1545. what was said:
  1546.  
  1547.  
  1548. >From millsp@gov.on.ca Fri Jul  1 07:22:10 1994
  1549.  
  1550.   I haven't used version 5 for a year or more, but I'm quite sure that
  1551. malloc was available...#include <stdlib.h> and add the ANSI library to
  1552. your project certainly works in v6 and its not something new I've added
  1553. during the upgrade.
  1554.  
  1555.   If you're looking to move away from Unix-isms, there are Toolbox
  1556. calls, NewPtr and DisposPtr, for memory management.
  1557.  
  1558.   (I've done a few small ports of things that started on Unix.  My major
  1559. problems have been trying to understand library calls that don't exist
  1560. and don't seem to have matching concepts on the Mac...fork?
  1561. yfork?...but most of them should be there.)
  1562.  
  1563.  
  1564. >From gardner@osm7.cs.byu.edu Fri Jul  1 10:32:54 1994
  1565.  
  1566. I port code from the Unix to the Mac and from the Mac to Unix all the time 
  1567. (and to the PC in between).  The main thing to keep in mind is *not* to use
  1568. UNIXisms or MACisms (or PCisms).  If you program in strictly ANSI C, you
  1569. will 
  1570. not have a problem going either direction.  Now that does eliminate taking 
  1571. advantage of platform specific features.  But thats actually what
  1572. portability 
  1573. is all about.  
  1574.  
  1575. As for malloc, include stdlib.h for the prototype and add ANSI to your
  1576. project and you are all set.  Note:  THINK C gives you a set of unix-like
  1577. functions 
  1578. in unix.h that help you compile *some* code containing some UNIXisms. 
  1579. However, 
  1580. most do not implement the semantics/behavior of the unix function (mostly
  1581. because they have no MAC equivalent).  I would not use them except as a
  1582. last 
  1583. resort.
  1584.  
  1585.  
  1586. >From VCHAVARR@samnet.jsc.nasa.gov Fri Jul  1 11:27:52 1994
  1587.  
  1588. One of the biggest differences between Mac and Unix systems is the way the 
  1589. operating system allocates memory. Unix uses pointers, Macs use handles, 
  1590. which are pointers to pointers. The malloc function tells the Unix system to 
  1591. allocate a certain amount of memory and returns a pointer to it. Macs use a 
  1592. function called NewHandle to allocate a block of memory, and a handle is 
  1593. returned.
  1594.  
  1595. There is a Mac function called NewPtr (in the memory.h file, I believe), 
  1596. which allocates a block of memory and returns a pointer to it. Allocating 
  1597. memory on a Mac with pointers, however, can be a bad idea because memory 
  1598. segmentation can occur, especially if you are allocating a lot of memory. 
  1599. You could replace all of the mallocs in your code with NewPtr, if you're not 
  1600. worried about memory segmentation. This has the advantage of you not having 
  1601. to make changes to your code in the parts where pointers are referenced. If 
  1602. you use NewHandle to replace malloc, however, you will have to go and find 
  1603. all of the places where pointers are referenced and make some changes.
  1604.  
  1605. Another area of difference between Unix and Macs are in the functions which 
  1606. are used to handle files. You can expect problems in this area if your Unix 
  1607. program reads or writes files.
  1608.  
  1609. - -------------------------------
  1610. --Gordan
  1611.  
  1612.  
  1613. ---------------------------
  1614.  
  1615. >From rick@akbar.cc.utexas.edu (Rick Watson)
  1616. Subject: Problems with Metrowerks vs. MPW 68k C calling conventions
  1617. Date: 29 Jun 1994 18:43:25 GMT
  1618. Organization: The University of Texas at Austin, Austin, Texas
  1619.  
  1620. Metrowerks 68k C passes short values on the stack as 16-bit
  1621. values where MPW uses 32 bits. This causes problems when trying
  1622. to call MPW generated code modules, including MacTCP's 
  1623. domain resolver code called by DNR.c. 
  1624.  
  1625. Is there an easy workaround for this that does NOT involve prototyping
  1626. the short values as longs? 
  1627.  
  1628. Rick Watson 
  1629. The University of Texas Computation Center, Networking Services, 512/471-8220
  1630.  r.watson@utexas.edu
  1631.  
  1632. +++++++++++++++++++++++++++
  1633.  
  1634. >From edandavi@well.sf.ca.us (Ed Allen and Avi Rappoport)
  1635. Date: 29 Jun 1994 22:47:27 GMT
  1636. Organization: The Whole Earth 'Lectronic Link, Sausalito, CA
  1637.  
  1638. rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1639.  
  1640. >Metrowerks 68k C passes short values on the stack as 16-bit
  1641. >values where MPW uses 32 bits. This causes problems when trying
  1642. >to call MPW generated code modules, including MacTCP's 
  1643. >domain resolver code called by DNR.c. 
  1644.  
  1645. >Is there an easy workaround for this that does NOT involve prototyping
  1646. >the short values as longs? 
  1647.  
  1648. Nope, there is no easy workaround.  Pascal libraries are fine, but C 
  1649. libraries have different parameter passing conventions, as you note 
  1650. above.  If you can get the source, compile it in MW.
  1651.  
  1652. Sorry.
  1653.  
  1654. -- 
  1655. Avi Rappoport                         (account also used by Ed Allen)
  1656. Systems Analyst and Technical Diplomat
  1657. metrowerks, Inc.
  1658. Please reply to: avirr@metrowerks.ca  avirr@aol.com  avirr@eworld.com
  1659.  
  1660. +++++++++++++++++++++++++++
  1661.  
  1662. >From mwron@aol.com (MW Ron)
  1663. Date: 29 Jun 1994 17:35:04 -0400
  1664. Organization: America Online, Inc. (1-800-827-6364)
  1665.  
  1666. In article <2usfcd$55p@geraldo.cc.utexas.edu>,
  1667. rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1668.  
  1669. >>Metrowerks 68k C passes short values on the stack as 16-bit
  1670. values where MPW uses 32 bits.
  1671. Is there an easy workaround for this that does NOT involve
  1672. prototyping
  1673. the short values as longs? 
  1674.  
  1675. Did you change the structure allignment in your preferences Processor
  1676. for 4 byte int and 8 byte doubles,  and use the proper Libraries? I
  1677. am not an MPW user so if this isn't the fix, please reply.
  1678.  
  1679. Ron Liechty
  1680. mwron@aol.com
  1681. Metrowerks Inc.
  1682.  
  1683.  
  1684. +++++++++++++++++++++++++++
  1685.  
  1686. >From johnmce@world.std.com (John McEnerney)
  1687. Date: Thu, 30 Jun 1994 05:42:45 GMT
  1688. Organization: The World Public Access UNIX, Brookline, MA
  1689.  
  1690. rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1691.  
  1692. >Metrowerks 68k C passes short values on the stack as 16-bit
  1693. >values where MPW uses 32 bits. This causes problems when trying
  1694. >to call MPW generated code modules, including MacTCP's 
  1695. >domain resolver code called by DNR.c. 
  1696.  
  1697. The problem is that although you may declare an argument 'short' or 
  1698. 'char' in MPW C, it will pass it as 32-bits. This was common in K&R 
  1699. compilers but is rare in ANSI compilers (THINK C does it the same way 
  1700. that we do)
  1701.  
  1702. The trick is to fool CW by declaring all integer arguments as 'long' in 
  1703. the prototype (including enums). Then the arguments will be properly 
  1704. extended to 32-bits.
  1705.  
  1706. -- John McEnerney, Metrowerks PowerPC Product Architect
  1707.  
  1708.  
  1709. +++++++++++++++++++++++++++
  1710.  
  1711. >From creiman@netcom.com (Charlie Reiman)
  1712. Date: Fri, 1 Jul 1994 05:36:05 GMT
  1713. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1714.  
  1715. mwron@aol.com (MW Ron) writes:
  1716.  
  1717. >In article <2usfcd$55p@geraldo.cc.utexas.edu>,
  1718. >rick@akbar.cc.utexas.edu (Rick Watson) writes:
  1719.  
  1720. >>>Metrowerks 68k C passes short values on the stack as 16-bit
  1721. >values where MPW uses 32 bits.
  1722. >Is there an easy workaround for this that does NOT involve
  1723. >prototyping
  1724. >the short values as longs? 
  1725.  
  1726. >Did you change the structure allignment in your preferences Processor
  1727. >for 4 byte int and 8 byte doubles,  and use the proper Libraries? I
  1728. >am not an MPW user so if this isn't the fix, please reply.
  1729.  
  1730. >Ron Liechty
  1731. >mwron@aol.com
  1732. >Metrowerks Inc.
  1733.  
  1734. Think C has the exact same feature, even with 4 byte ints turned on.  I
  1735. did call up Symantec tech support and argue about this. I can no longer
  1736. quote the K&R ANSI page number, but the behavior you are seeing is not
  1737. incorrect.
  1738.  
  1739. It's stupid, but not incorrect. 
  1740.  
  1741. You need prototypes under Think, MW may have another solution.
  1742.  
  1743. -- 
  1744. "You can't cancel the project! We already made the T-shirts!"
  1745. Charlie Reiman
  1746. creiman@netcom.com
  1747.  
  1748. +++++++++++++++++++++++++++
  1749.  
  1750. >From StevenEllis@microapl.demon.co.uk (Steven Ellis)
  1751. Date: Thu, 30 Jun 1994 10:50:06 GMT
  1752. Organization: MicroAPL
  1753.  
  1754.  
  1755. In article <2usfcd$55p@geraldo.cc.utexas.edu> rick@akbar.cc.utexas.edu (Rick
  1756. Watson) writes:
  1757. >Metrowerks 68k C passes short values on the stack as 16-bit
  1758. >values where MPW uses 32 bits. This causes problems when trying
  1759. >to call MPW generated code modules, including MacTCP's 
  1760. >domain resolver code called by DNR.c. 
  1761. >
  1762. >Is there an easy workaround for this that does NOT involve prototyping
  1763. >the short values as longs? 
  1764.  
  1765. If you look in the compiler preferences there is an option to use 4byte short
  1766. values.
  1767.  
  1768. >
  1769. >Rick Watson 
  1770. >The University of Texas Computation Center, Networking Services, 512/471-8220
  1771. > r.watson@utexas.edu
  1772. >
  1773.  
  1774. Steven Ellis
  1775.  
  1776. +++++++++++++++++++++++++++
  1777.  
  1778. >From johnmce@world.std.com (John McEnerney)
  1779. Date: Fri, 1 Jul 1994 15:23:53 GMT
  1780. Organization: The World Public Access UNIX, Brookline, MA
  1781.  
  1782. creiman@netcom.com (Charlie Reiman) writes:
  1783.  
  1784. >>>>Metrowerks 68k C passes short values on the stack as 16-bit
  1785. >>values where MPW uses 32 bits.
  1786. >>Is there an easy workaround for this that does NOT involve
  1787. >>prototyping
  1788. >>the short values as longs? 
  1789.  
  1790. >Think C has the exact same feature, even with 4 byte ints turned on.  I
  1791. >did call up Symantec tech support and argue about this. I can no longer
  1792. >quote the K&R ANSI page number, but the behavior you are seeing is not
  1793. >incorrect.
  1794. >It's stupid, but not incorrect. 
  1795.  
  1796. Everybody thinks that they're a compiler designer...
  1797.  
  1798. The ANSI standard clarified that when an argument is declared 'float', 
  1799. 'char' or 'short' it does not have to be widened to 'double' or 'int' 
  1800. when passed as an argument. (The only exception is when there is no 
  1801. prototype or for arguments matching the "...") It also clarified that a 
  1802. compiler is not required to pass arguments in reverse order when the 
  1803. number of arguments in known.
  1804.  
  1805. This permits ANSI compilers to generate much better code, in this case 
  1806. avoiding an EXT.W for each argument passed. Some compilers (including 
  1807. Symantec C++ I think) will pass arguments in the order that they are 
  1808. declared and will have the calleee strip the arguments, again contrary to 
  1809. K&R practice, but also usually more efficient.
  1810.  
  1811. I don't see why every compiler for the Mac has to be saddled with the 
  1812. calling conventions of a compiler that Apple hasn't done any work on in 5 
  1813. years.
  1814.  
  1815. -- John McEnerney, Metrowerks PowerPC Product Architect
  1816.  
  1817. +++++++++++++++++++++++++++
  1818.  
  1819. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  1820. Date: Fri, 1 Jul 1994 18:36:29 GMT
  1821. Organization: Apple Computer
  1822.  
  1823. Steven Ellis, StevenEllis@microapl.demon.co.uk writes:
  1824. > If you look in the compiler preferences there is an option to use 4byte
  1825. short
  1826. > values.
  1827.  
  1828. No, there is an option to use 4byte ints. shorts are always two bytes on
  1829. every Mac compiler (and on just about every other C compiler in the world,
  1830. with a few exceptions.) And shorts will always be pushed as 2 bytes by every
  1831. Mac compiler except MPW C.
  1832.  
  1833. I understand that Apple, Symantec and Metrowerks are hammering out a standard
  1834. C calling convention to be used by all their compilers, at least optionally
  1835. via pragmas. This becomes important with CFM and SOM on 68k, where C calling
  1836. conventions are used. (On PPC of course there is already one standard set of
  1837. calling conventions.)
  1838.  
  1839. --Jens Alfke
  1840.   jens_alfke@powertalk              Rebel girl, rebel girl,
  1841.             .apple.com              Rebel girl you are the queen of my world
  1842.  
  1843. +++++++++++++++++++++++++++
  1844.  
  1845. >From creiman@netcom.com (Charlie Reiman)
  1846. Date: Sat, 2 Jul 1994 00:43:50 GMT
  1847. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1848.  
  1849. johnmce@world.std.com (John McEnerney) writes:
  1850.  
  1851. >creiman@netcom.com (Charlie Reiman) writes:
  1852.  
  1853. >>>>>Metrowerks 68k C passes short values on the stack as 16-bit
  1854. >>>values where MPW uses 32 bits.
  1855. >>>Is there an easy workaround for this that does NOT involve
  1856. >>>prototyping
  1857. >>>the short values as longs? 
  1858.  
  1859. >>Think C has the exact same feature, even with 4 byte ints turned on.  I
  1860. >>did call up Symantec tech support and argue about this. I can no longer
  1861. >>quote the K&R ANSI page number, but the behavior you are seeing is not
  1862. >>incorrect.
  1863. >>It's stupid, but not incorrect. 
  1864.  
  1865. >Everybody thinks that they're a compiler designer...
  1866.  
  1867. >The ANSI standard clarified that when an argument is declared 'float', 
  1868. >'char' or 'short' it does not have to be widened to 'double' or 'int' 
  1869. >when passed as an argument. (The only exception is when there is no 
  1870. >prototype or for arguments matching the "...") It also clarified that a 
  1871. >compiler is not required to pass arguments in reverse order when the 
  1872. >number of arguments in known.
  1873.  
  1874. >This permits ANSI compilers to generate much better code, in this case 
  1875. >avoiding an EXT.W for each argument passed. Some compilers (including 
  1876. >Symantec C++ I think) will pass arguments in the order that they are 
  1877. >declared and will have the calleee strip the arguments, again contrary to 
  1878. >K&R practice, but also usually more efficient.
  1879.  
  1880. >I don't see why every compiler for the Mac has to be saddled with the 
  1881. >calling conventions of a compiler that Apple hasn't done any work on in 5 
  1882. >years.
  1883.  
  1884. Don't get me wrong. I understand what you are trying to do. I just
  1885. think the anguish it causes developers isn't worth the win in compiler
  1886. speed. Calling it 'stupid' may have been harsh but you weren't here
  1887. when I had to debug the problem it caused. Nor were you here when I had
  1888. to wedgie protoypes on top of 300,000+ lines of complex cross-platform
  1889. code to avoid future problems.
  1890.  
  1891. I may not be a compiler designer, but I sure do beat the crap out of
  1892. them.  I know what breaks and I simply have to disagree with you.
  1893.  
  1894. -- 
  1895. "You can't cancel the project! We already made the T-shirts!"
  1896. Charlie Reiman
  1897. creiman@netcom.com
  1898.  
  1899. +++++++++++++++++++++++++++
  1900.  
  1901. >From Lars.Farm@nts.mh.se (Lars Farm)
  1902. Date: Sat, 02 Jul 1994 11:56:40 +0100
  1903. Organization: Mid Sweden University
  1904.  
  1905. In article <1994Jul1.183629.27436@gallant.apple.com>, Jens Alfke
  1906. <jens_alfke@powertalk.apple.com> wrote:
  1907.  
  1908. > I understand that Apple, Symantec and Metrowerks are hammering out a standard
  1909. > C calling convention to be used by all their compilers, at least optionally
  1910. > via pragmas. This becomes important with CFM and SOM on 68k, where C calling
  1911. > conventions are used. (On PPC of course there is already one standard set of
  1912. > calling conventions.)
  1913.  
  1914. Isn't this a place for extern "OtherCallingConvention" void foo(int);
  1915. as in extern "C", or extern "MPW", or extern "ASLM", or extern "SOM", or
  1916. extern "CFM", or extern "Pascal", ... leaving internal calling conventions
  1917. as an implementation detail to the specific compiler vendor?
  1918.  
  1919. Instead of #pragmas or worse - project wide preferences.
  1920.  
  1921. Lars
  1922.  
  1923. -- 
  1924. Lars.Farm@nts.mh.se
  1925.  
  1926. ---------------------------
  1927.  
  1928. >From dnebing@bgsu.edu (  Mr. Neb)
  1929. Subject: Special #define for Univ. Hdrs?
  1930. Date: 3 Jul 1994 04:16:21 GMT
  1931. Organization: Bowling Green State University
  1932.  
  1933.   Here's a quicky: I just got done adding Univ. Hdrs. to TC7.0.3
  1934. (headers from develop 18 CD) and started to recompile some existing
  1935. code to see if it would fly without any serious modifications.
  1936.  
  1937.   Everything was going fine until I recompiled a project that was using
  1938. IconFamilies.h (for those of you who don't remember, IconFamilies.h
  1939. was the file defined in TechNote #306, "Drawing Icons the System 7
  1940. Way").  Everything from IconFamilies.h has been shuffled into Icons.h.
  1941.  
  1942.   Hey, that's fine with me.  But I would like to modify my source to
  1943. include IconFamilies.h if the univ. hdrs. are not available.  Easiest
  1944. way to do this, I says to myself, is to surround the #include with
  1945. an #ifndef.  The only problem is that I don't know if there is a
  1946. constant defined so that I can distinguish between the old headers
  1947. and the universal headers.
  1948.  
  1949.   So to wrap up, is there a constant defined somewhere within the
  1950. universal headers?
  1951.  
  1952. ============================================================
  1953. Dave Nebinger                    dnebing@andy.bgsu.edu
  1954. Network Manager, Biology Dept.   dnebing@opie.bgsu.edu
  1955. Bowling Green State University   dnebing@bgsuopie (bitnet)
  1956. Bowling Green, OH 43403          #include <std_disclaimer.h>
  1957.  
  1958.              *THE* alt.sources.mac supporter!
  1959.  
  1960.  
  1961. +++++++++++++++++++++++++++
  1962.  
  1963. >From al@crucible.powertools.com (Al Evans)
  1964. Date: 4 Jul 94 14:31:12 GMT
  1965. Organization: PowerTools, Austin, Texas
  1966.  
  1967. In article <2v5e2l$rm@falcon.bgsu.edu> dnebing@bgsu.edu (  Mr. Neb) writes:
  1968.  
  1969. >  So to wrap up, is there a constant defined somewhere within the
  1970. >universal headers?
  1971.  
  1972. I've been using #ifdef __CONDITIONALMACROS__. As far as I can tell,
  1973. <ConditionalMacros.h> gets included any time you're using the
  1974. universal headers, but doesn't exist if you're not.
  1975.  
  1976.                     --Al Evans--
  1977. -- 
  1978. Al Evans            |   Graphic Elements: A new standard for 
  1979.                 |   high-performance interactive Macintosh graphics.
  1980. al@crucible.powertools.com  |   Available from mac.archive.umich.edu
  1981.                 |   /mac/misc/demo/graphicelementsdemo.sit.hqx
  1982.  
  1983. +++++++++++++++++++++++++++
  1984.  
  1985. >From peter.lewis@info.curtin.edu.au (Peter N Lewis)
  1986. Date: Mon, 04 Jul 1994 10:32:51 +0800
  1987. Organization: NCRPDA, Curtin University
  1988.  
  1989. In article <2v5e2l$rm@falcon.bgsu.edu>, dnebing@bgsu.edu (  Mr. Neb) wrote:
  1990.  
  1991. >  Hey, that's fine with me.  But I would like to modify my source to
  1992. >include IconFamilies.h if the univ. hdrs. are not available.  Easiest
  1993. >way to do this, I says to myself, is to surround the #include with
  1994. >an #ifndef.  The only problem is that I don't know if there is a
  1995. >constant defined so that I can distinguish between the old headers
  1996. >and the universal headers.
  1997.  
  1998. Wow, another few years and this will be almost as much fun as trying to
  1999. get a unix program compiled.
  2000.  
  2001. I just love the C #define, #include method of seperate compilation. 
  2002. Brilian piece of design :-)
  2003.    Peter.
  2004. _______________________________________________________________________
  2005. Peter N Lewis <peter.lewis@info.curtin.edu.au>       Ph: +61 9 368 2055
  2006.  
  2007. ---------------------------
  2008.  
  2009. >From mdtaylor@apple.com (Mark D. Taylor)
  2010. Subject: Why does THINK C use a jump table?
  2011. Date: 17 Jun 1994 10:08:53 -0700
  2012. Organization: Apple Computer Inc, Cupertino, CA
  2013.  
  2014. Or more specifically, why does a call of a function in the same source file
  2015. and segment of the caller go through a jump table?
  2016.  
  2017. I'm having a problem with this because the call occurs at interrupt time
  2018. when A5 is not guaranteed and sometimes the jump table is not where the code
  2019. thinks it should be.
  2020.  
  2021. So what controls whether the jump table is used?  How can I disable it?
  2022.  
  2023. Thanks,
  2024. Mark
  2025.  
  2026.  
  2027. +++++++++++++++++++++++++++
  2028.  
  2029. >From doc@miracle.farallon.com (eric doc kampman)
  2030. Date: Fri, 17 Jun 1994 18:17:52 -0800
  2031. Organization: farallon
  2032.  
  2033. In article <2tslb5$d6c@apple.com>, mdtaylor@apple.com (Mark D. Taylor)
  2034. wrote:
  2035.  
  2036. > Or more specifically, why does a call of a function in the same source file
  2037. > and segment of the caller go through a jump table?
  2038. > I'm having a problem with this because the call occurs at interrupt time
  2039. > when A5 is not guaranteed and sometimes the jump table is not where the code
  2040. > thinks it should be.
  2041. > So what controls whether the jump table is used?  How can I disable it?
  2042.  
  2043. Short answer -- as far as I can tell, when one routine calls another it
  2044. *always* goes through the jump table -- even if the routine you're calling
  2045. is defined in the same source file and is 2 bytes away from the PC.  This
  2046. "feature" has caused me to retreat back to MPW when I'm not doing OOP
  2047. stuff.  You're going to have to save your A5 somewhere you can retrieve it
  2048. when you're not the front app.  There are many different situations where
  2049. this occurs and many ways of handling it.  For a generic solution -- check
  2050. out <SetUpA4.h> (in THINK #includes) for a *very* interesting way of saving
  2051. register values where you can get to them. It takes a little while to see
  2052. why what they're doing works (or at least it did for me).
  2053.  
  2054. -- 
  2055. doc@miracle.farallon.com
  2056. Farallon didn't write this, Farallon isn't responsible for its con-
  2057. tents -- Farallon is an abstract class and cannot be held responsible
  2058. for the quality of instantiations of derived classes.  
  2059. ********************************************************************
  2060.  Look for the thing you can't find/Seeing with eyes makes you blind
  2061.                You know you're out of your mind 
  2062.  
  2063. +++++++++++++++++++++++++++
  2064.  
  2065. >From siegel@netcom.com (Rich Siegel)
  2066. Date: Sat, 18 Jun 1994 01:20:21 GMT
  2067. Organization: Bare Bones Software
  2068.  
  2069. In article <2tslb5$d6c@apple.com> mdtaylor@apple.com (Mark D. Taylor) writes:
  2070. >Or more specifically, why does a call of a function in the same source file
  2071. >and segment of the caller go through a jump table?
  2072.  
  2073. (one of) Two reasons: it's not declared 'static', and/or you take its
  2074. address at some point in the code. If it's not declared static, it
  2075. needs to be accessible through the jump table so that other functions
  2076. can call it. If you take its address, it has to be indirected thruogh
  2077. the jump table to ensure position independence.
  2078.  
  2079. R.
  2080.  
  2081.  
  2082.  
  2083. -- 
  2084. Rich Siegel % siegel@netcom.com    % Principal, Bare Bones Software
  2085. --> For information about BBEdit, finger bbedit@world.std.com <--
  2086.  
  2087. "...yeah, I inhaled, and then I drank the bong water. So what're
  2088. you gonna do about it?" - Dennis Miller, on Bill Clinton
  2089.  
  2090. +++++++++++++++++++++++++++
  2091.  
  2092. >From gurgle@netcom.com (Pete Gontier)
  2093. Date: Sat, 18 Jun 1994 05:00:40 GMT
  2094. Organization: cellular
  2095.  
  2096. mdtaylor@apple.com (Mark D. Taylor) writes:
  2097.  
  2098. >Or more specifically, why does a call of a function in the same source
  2099. >file and segment of the caller go through a jump table? I'm having a
  2100. >problem with this because the call occurs at interrupt time when A5
  2101. >is not guaranteed and sometimes the jump table is not where the code
  2102. >thinks it should be. So what controls whether the jump table is used?
  2103. >How can I disable it?
  2104.  
  2105. You can't disable it without using another compiler, but you can make
  2106. sure your interrupt code works. First make sure the segment in question
  2107. is loaded by doing some work at non-interrupt time. Make a call into
  2108. the segment, perhaps to a dummy routine which exists solely to force
  2109. the segment to load. Make sure you don't subsequently call UnloadSeg
  2110. for that segment. Then, in your interrupt code, make sure A5 is set up
  2111. properly before you make the interrupt-time call into the segment. I
  2112. believe you will find relevant documentation in the usual places under
  2113. 'SetCurrentA5'.
  2114.  
  2115. None of this stuff is relevant under PowerPC, of course.
  2116. -- 
  2117.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2118.  
  2119.  'It seems the firm contracted by Intel to produce the famed "flying
  2120.  Pentium" ads could not complete the 3-D modeling on a PC before
  2121.  deadline. So in the best know-your-enemy tradition, they chose the next
  2122.  best thing -- a Quadra 840AV.'                 -- Mac The Knife 4/18/94
  2123.  
  2124. +++++++++++++++++++++++++++
  2125.  
  2126. >From gurgle@netcom.com (Pete Gontier)
  2127. Date: Sat, 18 Jun 1994 17:26:11 GMT
  2128. Organization: cellular
  2129.  
  2130. mdtaylor@apple.com (Mark D. Taylor) writes:
  2131.  
  2132. >Or more specifically, why does a call of a function in the same source
  2133. >file and segment of the caller go through a jump table?
  2134.  
  2135. Rich posted the reasons why, and I posted a way for you to make your
  2136. interrupt code work. But I don't think anybody yet has specifically
  2137. talked about the general case of how to make jump table entries go away.
  2138. If your routine is declared 'static' and you don't take its address,
  2139. *that* will guarantee it will not generate a jump table entry. (If your
  2140. routine is only referenced from its own segment, it will not generate a
  2141. jump table entry when building a stand-alone app, but it's more common
  2142. for programmers to want to run their app from TPM.)
  2143.  
  2144. This gives me an opportunity to be even a little more pedantic.
  2145.  
  2146. THINK C supports a language extension "require prototypes". Most people
  2147. should have it turned on (in the project settings dialog), because it
  2148. only helps you build safer and stronger software at the expense of some
  2149. extra typing sometimes. But most people don't know how to take advantage
  2150. of it. They turn it on, and the compiler encounters a function like
  2151. 'foo':
  2152.  
  2153.     void foo (void) { }
  2154.     void main (void) { foo ( ); }
  2155.  
  2156. ...and of course the compiler complains because there is no prototype
  2157. for 'foo' in scope. People's response is generally to give the compiler
  2158. a prototype, even for routines which will never be called from another
  2159. module:
  2160.  
  2161.     void foo (void);
  2162.         void foo (void) { }
  2163.         void main (void) { foo ( ); }
  2164.  
  2165. ...and this makes the compiler shut up. But there is a much better way:
  2166.  
  2167.     static void foo (void) { }
  2168.         void main (void) { foo ( ); }
  2169.  
  2170. ...this not only makes the compiler shut up, but it prevents 'foo'
  2171. from requiring a jump table entry, as long as you don't also take its
  2172. address. This not only keeps your jump-table less crowded, but it also
  2173. relieves you of having to deal with the possibility that A5 (or A4 in
  2174. some cases) is not valid when 'foo' is called. (If 'foo' is going to
  2175. call other routines which rely on A5 (or A4), 'foo' still needs to make
  2176. sure A5 (or A4) is valied before calling those other routines.)
  2177.  
  2178. Now, some people will say that relying on this behavior is a bad idea,
  2179. because the ANSI standard doesn't specify that 'static' should have
  2180. this effect. However, neither does the ANSI standard specify that a
  2181. feature like "require prototypes" be supported. When you hit the "ANSI
  2182. settings" button in the prefs dialog, notice that "infer prototypes"
  2183. gets selected, not "require prototypes". So since "require prototypes"
  2184. isn't ANSI in the first place, you might as well rely on the 'static'
  2185. keyword to help you use "require prototypes". I know CodeWarrior
  2186. supports it, by the way, and I suspect MPW C supports it in some similar
  2187. fashion, as well.
  2188.  
  2189. The reason I really like to use the 'static' keyword in this way is the
  2190. way THINK C segmentation works. You can only control segmentation at the
  2191. module level, so by definition 'static' routines cannot be called from
  2192. another segment. The linker simply won't cooperate. Using the 'static'
  2193. keyword in this way can prevent a whole layer of mistakes before they
  2194. require debugging time.
  2195. -- 
  2196.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  2197.  
  2198.  You thought Obfuscated C was confusing? Wait for Obfuscated C++!
  2199.  
  2200. +++++++++++++++++++++++++++
  2201.  
  2202. >From ari@world.std.com (Ari I Halberstadt)
  2203. Date: Mon, 20 Jun 1994 04:47:12 GMT
  2204. Organization: The World Public Access UNIX, Brookline, MA
  2205.  
  2206. In article <gurgleCrLsFo.3Hy@netcom.com>,
  2207. Pete Gontier <gurgle@netcom.com> wrote:
  2208. >...
  2209. >The reason I really like to use the 'static' keyword in this way is the
  2210. >way THINK C segmentation works. You can only control segmentation at the
  2211. >module level, so by definition 'static' routines cannot be called from
  2212. >another segment. The linker simply won't cooperate. Using the 'static'
  2213. >keyword in this way can prevent a whole layer of mistakes before they
  2214. >require debugging time.
  2215.  
  2216. There's another good reason to use this feature. It saves you from
  2217. having to put prototypes into the file, which means a bit less work
  2218. for the programmer/maintainer. It also helps give some logical
  2219. structure to your source files, since static functions need to be
  2220. defined before you can use them. If you really need to use a function
  2221. before it's defined, you can place a prototype for that function near
  2222. the head of the source file.
  2223. -- 
  2224. Ari Halberstadt                                 ari@world.std.com
  2225. One generation passes away, and another generation comes: but the
  2226. earth abides for ever. -- Ecclesiastes, 1:4.
  2227.  
  2228. +++++++++++++++++++++++++++
  2229.  
  2230. >From Aaron Wohl <aw0g+@andrew.cmu.edu>
  2231. Date: Fri,  1 Jul 1994 09:12:14 -0400
  2232. Organization: Systems Group 97, Carnegie Mellon, Pittsburgh, PA
  2233.  
  2234. There are two ways around think c using A5 to make calls:
  2235.  
  2236. a) have an lea instruction at the start of the routine (use asm {}) and
  2237. patch it before using the address at interrupt time.  (then flush the
  2238. code caches)
  2239.  
  2240. b) Compile the code in question as a code resource and load the resource.
  2241.  
  2242. See the code samples on akutaktak.andrew.cmu.edu [128.2.35.1] in the
  2243. /aw0g directory for some examples of using code resources.
  2244.  
  2245.  
  2246. ---------------------------
  2247.  
  2248. End of C.S.M.P. Digest
  2249. **********************
  2250.  
  2251.  
  2252. ˇ